Implement reconnection logic#24
Closed
mkmeral wants to merge 20 commits into
Closed
Conversation
added 20 commits
October 31, 2025 11:37
- Resolved class naming conflicts (kept new names: GeminiLiveModel, NovaSonicModel, OpenAIRealtimeModel) - Resolved Protocol vs ABC conflict (kept Protocol implementation) - Resolved event type conflicts (kept OutputEvent from bidi-event-types branch) - All tests passing
Resolved conflicts in novasonic.py and test_novasonic.py by keeping the current SessionStartEvent/SessionEndEvent naming convention (with session_id) instead of the older BidirectionalConnectionStart/End format (with connectionId). This aligns with the naming used in gemini_live.py and openai.py implementations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds automatic reconnection support to bidirectional streaming sessions, allowing agents to recover from transient connection failures without manual intervention.
Key Changes
Reconnection Feature:
enable_reconnection(default:True) andmax_reconnection_attempts(default:3) parameters toBidirectionalAgentError Handling:
_is_reconnectable_error()to identify connection-related errors (ConnectionError,ConnectionResetError,BrokenPipeError)_handle_connection_error()to manage reconnection attempts with proper error propagation_reconnect_session()to handle the reconnection process with configurable retry attemptsCode Quality Improvements:
_process_model_stream()by extracting_handle_model_event()for better separation of concerns_handle_interruption()print()tologger.info()Type System Updates:
turn_idparameter toInterruptionEvent(was missing, providers were passingNone)InputEventunion type in favor of explicit type unionsBehavior
When a connection error occurs during streaming:
_process_model_stream()max_reconnection_attemptstimes with 1-second pausesExample Usage